<template>
    <div class="card-box">
        <v-dialog :show.sync="dialogVisible" @beforeClose="beforeClose" width="70%" title="授权物业信息">
            <div v-if="dialogVisible">
                <el-table :row-style="{height:'50px'}"
                          :data="tableData" align="center"
                          style="width: 100%">
                    <el-table-column
                        prop="propertyId"
                        label="编号" height="">
                    </el-table-column>
                    <el-table-column
                        prop="authorizationNumber"
                        label="授权使用证">
                    </el-table-column>
                    <el-table-column
                        prop="propertyName"
                        label="物业名称">
                    </el-table-column>
                    <el-table-column
                        prop="propertyRightStr"
                        label="物业产权">
                    </el-table-column>
                    <el-table-column
                        prop="serviceLife"
                        label="使用期限">
                    </el-table-column>
                    <el-table-column
                        prop="projectType"
                        label="用途大类"
                        :formatter="dictVal_projectTypes"
                    >
                    </el-table-column>
                    <el-table-column
                        prop="projectSubclassType"
                        label="用途小类"
                        :formatter="dictVal_SubProjectTypes"
                    >
                    </el-table-column>
                    <el-table-column
                        prop="useStatus" :formatter="dictVal_useStatus"
                        label="状态">
                    </el-table-column>
                </el-table>

            </div>
            <div slot="foot">
                <el-button type="primary" size="small" @click="dialogVisible = false" style="width: 80px">关闭</el-button>
            </div>
        </v-dialog>
    </div>
</template>


<script>
    import {getPropertyList} from "@/views/authorization-management/apply-unit/api/apply-unit.js";
    import {getDict} from "~/utils";

    export default {
        name: "base-info",
        data() {
            return {
                //弹出框 初始时隐藏
                dialogVisible: false,
                apUiId: "",
                //使用状态
                useStatusCode: [],
                tableData: [
                    "cardPropertyId"
                ],
                projectTypes:[],
                projectSubclassTypes:[]


            }
        },
        mounted () {
        },
        created() {
            this.useStatusCode = getDict('use-status');
            this.projectTypes=getDict('property_types');
            this.projectSubclassTypes=getDict('property_use_types');
        },
        methods: {
            /**
             * 示新增弹框
             */
            show(rowData) {
                this.loading = false
                this.dialogVisible = true
                this.apUiId = rowData.apUiId;
                this.tableData = [];
                this.query();
            },


            /**
             * 关闭弹窗
             * @param done
             */
            beforeClose(done) {
                this.dialogVisible = false
                done();
            },


            /**
             * 查询方法
             * @param param
             */
            query() {
                getPropertyList(this.apUiId).then(respData => {
                    this.tableData = respData.data.data;
                    if (null != this.tableData && this.tableData.length > 0) {
                        for (let i = 0; i < this.tableData.length; i++) {
                            if (this.tableData[i].propertyRight == 1) {
                                this.tableData[i].propertyRightStr ="自有";
                            } else if (this.tableData[i].propertyRight == 2) {
                                this.tableData[i].propertyRightStr ="租用";
                            } else {
                                this.tableData[i].propertyRightStr ="其他";
                            }
                        }
                    }
                }).catch(error => {
                    this.$message({
                        type: 'error',
                        message: '查询失败'
                    });
                });
            },
            /**
             * 码值转换
             * @param row
             * @param column
             * @param cellValue
             * @returns {string|*}
             */
            dictVal_useStatus: function (row, column, cellValue) {
                let obj = this.useStatusCode.find(p => p.value == cellValue)
                if (obj) {
                    return obj.label
                }
                return '';
            },

            dictVal_projectTypes: function (row, column, cellValue) {
                let obj = this.projectTypes.find(p => p.value == cellValue)
                if (obj) {
                    return obj.label
                }
                return '';
            },

            dictVal_SubProjectTypes: function (row, column, cellValue) {
                let obj = this.projectSubclassTypes.find(p => p.value == cellValue)
                if (obj) {
                    return obj.label
                }
                return '';
            },



        }


    }
</script>

<style scoped lang='scss'>


    @include formWrap();

</style>
